#include "widget.h"
#include "ui_widget.h"
#include <QMovie>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    ui->stackedWidget->setCurrentIndex(1);

    connect(ui->btn_toolbox, &QPushButton::clicked, this, [=](){
        ui->stackedWidget->setCurrentIndex(0);
    });

    connect(ui->btn_screllArea, &QPushButton::clicked, this, [=](){
        ui->stackedWidget->setCurrentIndex(1);
    });

    connect(ui->btn_tabWidget, &QPushButton::clicked, this, [=](){
        ui->stackedWidget->setCurrentIndex(2);
    });

    //下拉框的使用
    ui->comboBox->addItem("奔驰");
    ui->comboBox->addItem("宝马");
    ui->comboBox->addItem("拖拉机");

    //点击按钮，选择拖拉机下拉框的内容
    connect(ui->btn_setComboxValue, &QPushButton::clicked, this, [=](){
        //ui->comboBox->setCurrentIndex(2);
        ui->comboBox->setCurrentText("拖拉机");
    });

    //利用QLabel显示图片
    ui->label_image->setPixmap(QPixmap(":/resources/static/resources/1001.jpg"));


    //利用QLabel显示动态图片， 格式要求gif
    QMovie * movie = new QMovie(":/resources/static/resources/1005.gif");
    ui->label_movie->setMovie(movie);
    movie->start();
}

Widget::~Widget()
{
    delete ui;
}
